package com.jinbei.config;


import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



/**
 * @author zflu
 * ehcache 配置类
 */
@Configuration
public class EhCacheConfig{

    @Bean(name = "ehCacheManager")
    public static CacheManager cacheManager(){
        CacheConfiguration cacheConfig = new CacheConfiguration();
        cacheConfig.setName("course");
        cacheConfig.setMemoryStoreEvictionPolicy("LRU");
        cacheConfig.setMaxEntriesLocalHeap(1000);
        cacheConfig.setEternal(true);
        net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
        config.addCache(cacheConfig);
        CacheManager cacheManager = CacheManager.newInstance(config);
        return cacheManager;
    }


}